from django.db import models
from django.utils import timezone
# Create your models here.


class Post(models.Model):
    """
    文章的数据库表稍微复杂一点，主要是涉及的字段更多。
    django会自动新建自增id作为主键
    """
    title = models.CharField(verbose_name='标题',max_length=70) # 标题
    body =  models.TextField(verbose_name='正文',blank=True, null=True)
    post_url = models.CharField(verbose_name='URL地址',max_length=200,blank=True,null=True)# 图片地址
    publish = models.DateTimeField(verbose_name='发布时间', default=timezone.now)  # 发布时间


    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-publish']
        verbose_name_plural  = " 接口地址"

